package database.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import database.pojo.UserConsumeInfo;



/**
 * 类名:UserConsumeDao
 * 描述:对用户消费表数据库的封装
 * @author zk
 * @date 2018-4-20
 * @version 0.0.1
 *
 */
public class UserConsumeDao{
	public boolean insert(UserConsumeInfo uInfo, Connection conn ) throws SQLException {
		String sqlInsert = "insert into user_consume(order_type, mount, order_sn,mid,status,pay_time,description,uid) "
				+ "values( ? , ? , ?, ?, ?,	?,	?,	? )";
		PreparedStatement pstmt = null;
		boolean result = true;
		try{
			pstmt = conn.prepareStatement(sqlInsert);//相当于python操作数据库的游标
			pstmt.setInt(1, uInfo.getOrder_type());
			pstmt.setDouble(2, uInfo.getMount());
			pstmt.setString(3, uInfo.getOrder_sn());
			pstmt.setInt(4, uInfo.getMid());
			pstmt.setInt(5, uInfo.getStatus());
			pstmt.setString(6, uInfo.getPay_time());
			pstmt.setString(7, uInfo.getDescription());
			pstmt.setInt(8, uInfo.getUid());
			pstmt.executeUpdate();
		}catch (Exception e) {
			System.out.println(" UserConsumeDao insert Exception" + e);
			result = true;
		}
		finally{
			if(pstmt != null){
				pstmt.close();
			}
		}
		return result;
		
	}
	
}